export const request = async (url: string, options?: RequestInit) => {
  const baseURL = import.meta.env.VITE_API_BASE_URL || ''  // 从环境变量获取基础URL
  const fullURL = `${baseURL}${url}`
  console.log('Making request to:', fullURL)  // 添加日志
  
  try {
    const response = await fetch(fullURL, {
      ...options,
      headers: {
        'Content-Type': 'application/json',
        ...options?.headers,
      },
    })
    
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`)
    }
    
    return await response.json()
  } catch (error) {
    console.error('Request error:', error)  // 添加日志
    throw error
  }
} 